package com.gohi.core.dao;


import com.gohi.core.web.paging.PagingBean;

import java.io.Serializable;
import java.sql.Connection;
import java.util.List;

import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.orm.hibernate3.HibernateTemplate;
import org.springframework.transaction.TransactionException;


public abstract interface IDAO<T,PK extends Serializable> {
	
	
	/**获取JDBC模版*/
	public abstract JdbcTemplate getJdbcTemplate();
	/**获取Hibernate模版*/
	public abstract HibernateTemplate getHibernateTemplate();
	
	public abstract T save(T entity) throws TransactionException;


	public abstract T getByPK(T entity,PK id)throws TransactionException;

	public abstract void remove(T entity,PK id)throws TransactionException;

	
	public abstract Long getCount(String queryString, final Object[] values)throws TransactionException;
	

	/**
	 * 根据实体Bean取记录集
	 * @author 湘龙
	 * @param entity 实体Bean
	 * @return  结果集
	 * */
	public abstract List<T> getAll()throws TransactionException;

	/**
	 * 根据实体Bean取记录集，分页
	 * @author 湘龙
	 * @param entity 实体Bean
	 * @param paramPagingBean	分页Bean
	 * @return  结果集
	 * */
	public abstract List<T> getAll(T entity,PagingBean paramPagingBean)throws TransactionException;

	/**
	 * 根据HQL取记录集
	 * @param paramString 	HQL语句，参数以T代替
	 * @param paramArrayOfObject	参数数组
	 * */
	public abstract List<T> findByHql(String paramString,
			Object[] paramArrayOfObject)throws TransactionException;

	/**
	 * 根据HQL，分页Bean取记录集，分页
	 * @param paramString 	HQL语句，参数以T代替
	 * @param paramArrayOfObject	参数数组
	 * @param paramPagingBean 分页Bean
	 * */
	public abstract List<T> findByHql(String paramString,
			Object[] paramArrayOfObject, PagingBean paramPagingBean)throws TransactionException;

	/**
	 * 根据HQL，页码取记录集，分页
	 * @param paramString 	HQL语句，参数以T代替
	 * @param paramArrayOfObject	参数数组
	 * @param paramPagingBean 分页Bean
	 * @param paramInt1	页码
	 * @param paramInt2	最大结果数
	 * */
	public abstract List<T> findByHql(String paramString,
			Object[] paramArrayOfObject, int paramInt1, int paramInt2)throws TransactionException;
	
}